import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
// 解决报错
const originalPush = VueRouter.prototype.push
const originalReplace = VueRouter.prototype.replace
// push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
// replace
VueRouter.prototype.replace = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
  return originalReplace.call(this, location).catch(err => err)
}

import My from '@/views/My'

const routes = [
 
  {
    path: '/',
    component: ()=>import('../Layout/index.vue'),
    redirect: 'home',
    children:[
      {
        path:'/home',
        name:'home',
        component:()=>import('../views/home/homeIndex.vue')
      },
      {
        path:'/snap',
        component:()=>import('../views/home/homeSnap.vue')
      },
      {
        path:'/rank',
        component:()=>import('../views/home/homeRank.vue')
      },
      {
        path:'/notify',
        component:()=>import('../views/home/homeNotify.vue')
      },
      {
        path:'/searching',
        component:()=>import('../views/search/searching.vue')
      },
      {
        path:'/searResult',
        name:'searResult',
        component:()=>import('../views/search/searResult.vue')
      },
      {
        path:'/detail/:id',
        name:'detail',
        component:()=>import('../views/detail.vue')
      },
     
    ]
  },
  {
    path:'/my',
    component:My
  },
  {
    path:'/setup',
    component:()=>import('@/views/My/setup')
  },
  {
    path:'/login',
    component:()=>import('@/views/My/login')
  },
  {
    path:'/address',
    component:()=>import('@/views/My/address/')
  },
  {
    path:'/setupMy',
    component:()=>import('@/views/My/setup/setuoMy')
  },
  {
    path:'/register',
    component:()=>import('@/views/My/setup/setuoMy/register')
  },
  {
    path:'/findshopp',
    component:()=>import('@/views/findshopp')
  },
  {
    path:'/order',
    component:()=>import('@/views/My/order/index.vue')
  },
  {
    path:'/side',
    component:()=>import('../views/side')
  },
  {
    path:'/shoppingCart',
    component:()=>import('../views/shoppingCart/index.vue')
  }
  

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
